<?php

class ThongKeController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column2';
    public $defaultAction = 'admin';
	/**
	 * @return array action filters
	 */
	public function filters()
	{
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}

     function checkAdmin($user)
    {
        $loginName = $user->getState('login_name');
        if($loginName != 'hanguyen' || $loginName != 'administrator')
            return false;
        return true;
    }

    public function accessRules()
    {
        return array(
            array('deny',  // deny all users
                    'actions'=>array('admin'),
                    'expression'    =>    array($this, 'checkAdmin'),
                ),

            array('deny',
                    'actions'=>array('admin'),
                    'users'    => array('?'),
            ),
        );
    }

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */

	public function actionAdmin()
	{
		$model=new Coincard('search');
		$model->unsetAttributes();  // clear any default values
		if(isset($_GET['Coincard']))
			$model->attributes=$_GET['Coincard'];

		$this->render('admin',array(
			'model'=>$model,
		));
	}

}
